using System;
using System.Windows.Forms;
using Habanero.BO;
using Habanero.Faces.Base;
using Habanero.Faces.Win;
using Habanero.Base;
using log4net;
using log4net.Config;
using <<BOPROJECT_NAME>>;

namespace <<NAMESPACE>>
{
    static class Program
    {
		private static readonly ILog log = LogManager.GetLogger(typeof(Program));
    
        [STAThread]
        static void Main()
        {
			GlobalRegistry.ApplicationName = "<<APPLICATION_NAME>>";
			GlobalRegistry.ApplicationVersion = "<<PROJECT_VERSION>>";        
            HabaneroAppWin mainApp = new HabaneroAppWin(GlobalRegistry.ApplicationName, GlobalRegistry.ApplicationVersion);
	    	mainApp.ClassDefsXml = BOBroker.GetClassDefsXml();
            try
            {
                log.Debug(string.Format("-------- {0} {1} Starting  ---------", GlobalRegistry.ApplicationName, GlobalRegistry.ApplicationVersion));
				if (!mainApp.Startup()) return;
                // Uncomment the next line of code to use an "In Memory" data accessor (instead of your Database).
                //BORegistry.DataAccessor = new DataAccessorInMemory();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }

            try
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                
                FormWin programForm = new FormWin();
                new UIManagerWin().SetupMainForm(programForm);
                Application.Run(programForm);
            }
            catch (Exception ex)
            {
                GlobalRegistry.UIExceptionNotifier.Notify(ex,
					"An error has occurred in the application.",
					"Application Error");
            }
        }
    }
}